<script lang="ts" setup>
	import {
		ref,
		defineProps,
		getCurrentInstance,
		reactive
	} from "vue";
	import {
		userStore
	} from '@/pinia';
	import {
		useRouter
	} from 'uni-mini-router'
		import * as im from '@/common/im.js';
	const router = useRouter()
	const state = reactive({
		userInfo:{}
	})
	const {
		proxy,
	} = getCurrentInstance()
	let tabbarValue = ref('')
		let detailObj = ref({})
	const Props = defineProps<{
		name ?: string | object
	}>()
	tabbarValue.value = Props.name
	console.log(tabbarValue.value, 'name');
	const tabbarChange = (e) => {
		console.log(e, 'tabbar');
		tabbarValue.value = e
	}
		const userStoreInfo = userStore();
		const getMeiyeRecruitHrInfo3QueryById = ()=>{
		proxy.$req('GET', proxy.$api.meiyeRecruitHrInfo3QueryById, {id:userStoreInfo.userInfo.id}).then((res) => {
			console.log(res);
			if(res.code === 200){
				state.userInfo = res.result
			}
		})
	}
	const routerLink = (obj, e) => {
		console.log(obj, e, 'duixiang');
		
	
		
		if (typeof obj == 'string') {
			router.push({
				name: e,
				params: {type :'1'}
			})
		}
	}
	
	// 聊一聊
	const toIm = () => {
		const { memberId } = userStoreInfo.userInfo.id;
		//console.log('investmentCenter   detailObj.value', detailObj.value,memberId);
		// console.log('state.detailsData', state.detailsData);
		// #ifdef APP-PLUS
		im.init({
			imFlag: 'investmentCenter',
			toUserId: memberId,
		}, () => {
			router.push({
				// name: 'ConversationListPage',
				name: 'ConversationPage',
			})
		})
		// #endif
	}
	

	const	messageType =(type) =>{
		uni.navigateTo({
			url:`/pages/im/conversationList/recruit?type=${type}`
		})
	}
	
</script>
<template>
	<u-tabbar :value="tabbarValue" @change="tabbarChange" :fixed="true" :placeholder="false"
		:safeAreaInsetBottom="false" activeColor="#CB645E">
		<u-tabbar-item text="牛人" name="worker" @click="routerLink($event,'worker')">
			<template #active-icon>
				<image
					class="slot-icon"
					src="/static/tabbar2/oneS.png"
				></image>
			</template>
			<template #inactive-icon>
				<image
					class="slot-icon"
					src="/static/tabbar2/one.png"
				></image>
			</template>
		</u-tabbar-item>
		<u-tabbar-item text="聊一聊" name="chat" @tap="messageType(1)">
			<template #active-icon>
				<image
					class="slot-icon"
					src="/static/tabbar2/twoS.png"
				></image>
			</template>
			<template #inactive-icon>
				<image
					class="slot-icon"
					src="/static/tabbar2/two.png"
				></image>
			</template>
		</u-tabbar-item>
		<u-tabbar-item text="职位"  name="postJob" @click="routerLink($event,'postJob')">
			<template #active-icon>
				<image class="slot-icon" src="/static/tabbar2/threeS.png"></image>
			</template>
			<template #inactive-icon>
				<image
					class="slot-icon"
					src="/static/tabbar2/three.png"
				></image>
			</template>
		</u-tabbar-item>
		<u-tabbar-item text="我的" name="bossMine" @click="routerLink($event,'bossMine')">
			<template #active-icon>
				<image
					class="slot-icon"
					src="/static/tabbar2/fourS.png"
				></image>
			</template>
			<template #inactive-icon>
				<image
					class="slot-icon"
					src="/static/tabbar2/four.png"
				></image>
			</template>
		</u-tabbar-item>
	</u-tabbar>
</template>
<style lang="scss">
.slot-icon{
	width:40rpx;
	height:40rpx;
}
</style>